import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
import {getLyric} from '../api/demo'
export default new Vuex.Store({
  //data
  state: {
    // 播放时间
    current:'',
    //播放列表
    playList: [
      // {
      //   id:"",
      //   name:"",
      //   pic:"",
      // }
    ],
    //默认展示下标
    playListIndex:0,
    //控件播放暂停显示隐藏
    show:false,
    //控件歌词弹窗显示隐藏
  isShow:false,
  //存放歌词数据
  lyricList:{},
  },
  getters: {},
  
  mutations: {
    updatacurrent(state,value){
      state.current = value;
      //console.log("当前播放时间",state.current);
    },
    //更新歌词显示隐藏
    updataIsshow(state){
      state.isShow = !state.isShow;
    },
    //更新show属性
    updataShow(state,value){
      state.show = value;
    },
    //更新播放列表=赋值
    updataplayList(state,value){
      state.playList = value;
      console.log("更新后的列表",state.playList);
    },
    //更新播放下标=赋值
    updataIndex(state,value){
      state.playListIndex = value
    },
    updataLyricList(state,value){
      state.lyricList = value;
      console.log("更新之后的歌词",state.lyricList);
    },
  },
  actions: {
    //获取歌词
    async getLyricData(context,id){
      let res = await getLyric(id);
      console.log("歌词信息",res);
      context.commit("updataLyricList",res.data.lrc);
    },
  },
  modules: {
  }
})
